<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增鸡出库')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-ncOutputChicken-add">
			<!--<div class="form-group">
				<label class="col-sm-3 control-label">菜房订单id：</label>
				<div class="col-sm-8">
					<input id="cforderId" name="cforderId" class="form-control" type="text">
				</div>
			</div>-->
			<div class="form-group">
				<label class="col-sm-3 control-label">库存:</label>
				<div class="col-sm-8">
					<select name="outputId" id="outputId" class="form-control m-b">
						<option th:each="chicken:${inputChicken}" th:amount="${chicken.stackAmount}" th:value="${chicken.inputId}" th:text="${chicken.inputCode} +'鸡' +'-('+${chicken.stackAmount}+')只'"></option>
					</select>
				</div>
			</div>
			<input type="hidden" name="outputStatus" value="2"/>
			<div class="form-group">	
				<label class="col-sm-3 control-label">出库日期：</label>
				<div class="col-sm-8">
					<input type="text" style="height: 34px;" data-format="yyyy-MM-dd HH:mm:ss" th:value="*{#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd HH:mm:ss')}"  data-type="datetime" name="outputTime" class="time-input" id="outputTime"/>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">需求数量（只）：</label>
				<div class="col-sm-8">
					<input id="requestAmount" name="requestAmount" class="form-control" type="number" onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')" min="0">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">供应数量（只）：</label>
				<div class="col-sm-8">
					<input id="outputAmount" name="outputAmount" class="form-control" type="number" onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')" min="0" required>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">供应大鸡数量（只）：</label>
				<div class="col-sm-8">
					<input id="outputAmountBig" name="outputAmountBig" class="form-control" type="number" onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')" min="0">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">供应小鸡数量（只）：</label>
				<div class="col-sm-8">
					<input id="outputAmountLittle" name="outputAmountLittle" class="form-control" type="number" onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')" min="0">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">出库类型:</label>
				<div class="col-sm-8">
					<select name="outputType" required class="form-control m-b" th:with="type=${@dict.getType('outputType')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">抓鸡时间：</label>
				<div class="col-sm-8">
					<input type="text" style="height: 34px;" data-format="yyyy-MM-dd HH:mm:ss"  th:value="*{#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd HH:mm:ss')}" name="catchTime" class="time-input" id="catchTime"/>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">母鸡状态:</label>
				<div class="col-sm-8">
					<select name="chickenStatus" required class="form-control m-b" th:with="type=${@dict.getType('chickenStatus')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">宰杀时间：</label>
				<div class="col-sm-8">
					<input type="text" style="height: 34px;" data-format="yyyy-MM-dd HH:mm:ss"  th:value="*{#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd HH:mm:ss')}" name="killTime" class="time-input" id="killTime"/>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">宰杀后成品母鸡标准 ：</label>
				<div class="col-sm-8">
					<select name="isHealthy" required class="form-control m-b" th:with="type=${@dict.getType('isHealthy')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">宰杀人员：</label>
				<div class="col-sm-8">
					<select name="butcher" id="butcher" class="form-control m-b">
						<option th:each="user:${userList}" th:value="${user.loginName}" th:text="${user.loginName}"></option>
					</select>

				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">菜房接收时间：</label>
				<div class="col-sm-8">
					<input type="text" style="height: 34px;" data-format="yyyy-MM-dd HH:mm:ss"  th:value="*{#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd HH:mm:ss')}" name="receiveTime" class="time-input" id="receiveTime"/>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">菜房接收人员：</label>
				<div class="col-sm-8">
					<select name="receiver" id="receiver" class="form-control m-b">
						<option th:each="user:${userList}" th:value="${user.loginName}" th:text="${user.loginName}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">出库经手人：</label>
				<div class="col-sm-8">
					<select name="outputUser" id="outputUser" class="form-control m-b">
						<option th:each="user:${userList}" th:value="${user.loginName}" th:text="${user.loginName}"></option>
					</select>
				</div>
			</div>
			<!--<div class="form-group">
				<label class="col-sm-3 control-label">创建者：</label>
				<div class="col-sm-8">
					<input id="createBy" name="createBy" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">创建时间：</label>
				<div class="col-sm-8">
					<input id="createTime" name="createTime" class="form-control" type="text">
				</div>
			</div>-->
			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea id="remark" name="remark"  class="form-control valid" type="text" rows="4"></textarea>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "system/ncOutputChicken"
		$("#form-ncOutputChicken-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});
		
		function submitHandler() {
			var inputamount=$('#outputId').find("option:selected").attr("amount");
			var outputAmount=$("#outputAmount").val();
			if(parseInt(outputAmount) > parseInt(inputamount)){
				$.modal.alertWarning("所选批次库存不足！");
			}
			else if($("#outputAmountBig").val() != '' || $("#outputAmountLittle").val() != ''){
				if((parseInt($("#outputAmountBig").val())+parseInt($("#outputAmountLittle").val())) != parseInt(outputAmount)){
					$.modal.alertWarning("大小鸡数量之和要与供应数量一致！");
				}
				else{
					if ($.validate.form()) {
						$.operate.save(prefix + "/add", $('#form-ncOutputChicken-add').serialize());
					}
				}
			}
            else{
                if ($.validate.form()) {
                    $.operate.save(prefix + "/add", $('#form-ncOutputChicken-add').serialize());
                }
			}

	    }
	</script>
</body>
</html>
